
// 随页面加载查询优惠券信息
$(function () {
    var user_data = {};
    var succCallBack = function (data, status, response) {
        if(data.errorCode=="0") {
            var dataInter=data.data;
            var interText = doT.template($("#coupon_option").text());
            $("#coupon").html(interText(dataInter));
        }

        // 数据回显
        $("#title").val(getQueryString("title"));
        $("#issue_started_at").val(getQueryString("issue_started_at"));
        $("#issue_end_in").val(getQueryString("issue_end_in"));
        $("#issue_count").val(getQueryString("coupon_id"));
        $("#coupon").val(getQueryString("coupon_id"));
    };
    web.doAjax("http://192.168.8.249:8088/operation/select_promotion_coupon.jhtml", 'post', user_data, succCallBack);
});

$("#form-member").validate({
    rules: {
        biaoti: {
            maxlength:10,
            minlength:10,
        },
        file: {
            maxlength:30,
        },
        url: {
            maxlength:10,
            minlength:10,
        },
        logmin: {
            maxlength:10,
            minlength:10,
        },
        logmax: {
            maxlength:10,
            minlength:10,
        },
        lunbo: {
            maxlength:10,
            minlength:10,
        }
    },
    //提交表单数据
    submitHandler:function(form){
        //获取
        var title=$("#title").val(),
            coupon_id = $("#coupon").val(),
            coupon_name = $("#coupon").find("option:selected").text(),
            issue_started_at = $("#issue_started_at").val(),
            issue_end_in = $("#issue_end_in").val(),
            issue_count = $("#issue_count").val(),
            promotion_id = getQueryString("promotion_id")
        //提交
        var user_data = {
            title : title,
            coupon_id : coupon_id,
            coupon_name : coupon_name,
            issue_started_at : issue_started_at,
            issue_end_in : issue_end_in,
            issue_count : issue_count,
            promotion_id : promotion_id
        };
        //获取返回的数据
        var succCallBack = function (data, status, response) {
            console.log(data);
            if(data.errorCode=="0") {
                layer.msg('操作成功!', {icon: 6, time: 1000});
            }
        }

        //给一个接口地址提交数据
        return web.doAjax("http://192.168.8.249:8088/operation/save_promotion_conf.jhtml", 'post', user_data, succCallBack);
    }
})
// //初始化客户归属下拉列表
// function ascription() {
//     var user_data = {}
//     var succCallBack = function (data, status, response) {
//         //console.log(data)
//         if (data.errorCode == "0") {
//             var dataInter = data.group;
//             var interText = doT.template($("#ascription_bob").text());
//             $("#ascription_lsit").html(interText(dataInter));
//         }
//     };
//     return web.doAjax(root.inter.getGroup, 'post', user_data, succCallBack);
// }